<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>文章管理-{$tpshop_config['shop_info_store_title']}</title>
    <meta name="keywords" content="{$tpshop_config['shop_info_store_keyword']}" />
    <meta name="description" content="{$tpshop_config['shop_info_store_desc']}" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/tpshop.css" />
    <link rel="stylesheet" type="text/css" href="__STATIC__/css/myaccount.css" />
    <script src="__STATIC__/js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
    <load href="__ROOT__/public/plugins/Ueditor/ueditor.config.js"/>
    <load href="__ROOT__/public/plugins/Ueditor/ueditor.all.min.js"/>
    <script type="text/javascript" charset="utf-8" src="__ROOT__/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"></script>
    <script src="__ROOT__/public/static/js/layer/laydate/laydate.js"></script>
</head>
<style>
    /*按钮*/
    a.ncap-btn-big {
        font: bold 14px/20px "microsoft yahei", arial;
        color: #ebf8fd;
        background-color: #ECF0F1;
        text-align: center;
        vertical-align: middle;
        display: inline-block;
        height: 20px;
        padding: 7px 19px;
        border: solid 1px #BEC3C7;
        border-radius: 3px;
        cursor: pointer;
    }
    a:hover.ncap-btn-big {
        text-decoration: none;
        color: #FFF;
        background-color: #BEC3C7;
        box-shadow: 0 0 0 2px rgba(82, 168, 236, 0.15);
    }
    a.ncap-btn-green,
    a:hover.ncap-btn-green,
    a:hover.ncap-btn-green {
        background-color: #3aa8cf;
    }
    .row {
        margin-top: 10px
    }
    .row .tit{
        text-align: left;
        padding-right: 2%;
        font-size: 14px;
        line-height: 24px;
        vertical-align: top;
        letter-spacing: normal;
        display: inline-block;
    }
    .row .tit label{
        font-size: 14px;
    }
    .row .opt{
        font-size: 12px;
        line-height: 24px;
        vertical-align: top;
        letter-spacing: normal;
        display: inline-block;
    }
    .row input{
        border: 1px solid #ccc;
        white-space: nowrap;
        display: inline-block;
        width: 750px;
        line-height: 20px;
        height: 30px;
        overflow: hidden;
        cursor: text;
    }


</style>
<body class="bg-f5">
<include file="user/header"/>
<div class="home-index-middle">
    <div class="w1224">
        <div class="g-crumbs">
            <a href="{:U('Home/User/index')}">我的商城</a>
        </div>
        <div class="home-main">
            <include file="user/menu"/>
            <div class="ri-menu fr">
                <div class="order-list p">
                    <div class="ddlb-ayh">
                        <div class="ddlb-tit">
                            <h1>新建文章</h1>
                            <i class="u-sep"></i>
                            <a class="u-view-pre" href="{:U('Home/User/articleList')}">返回列表</a>
                        </div>
                        <div class="order-alone-li" style="margin-top: 35px">
                            <form class="form-horizontal" action="{:U('Article/aticleHandle')}" id="add_post"
                                  method="post">
                                <div class="ncap-form-default">
                                    <dl class="row">
                                        <dt class="tit">
                                            <label>标题</label>
                                        </dt>
                                        <dd class="opt">
                                            <input type="text" value="{$info.title}" name="title" class="input-txt">
                                            <span class="err" id="err_title"></span>
                                            <p class="notic"></p>
                                        </dd>
                                    </dl>
                                    <dl class="row">
                                        <dt class="tit">
                                            <label>内容</label>
                                        </dt>
                                        <dd class="opt" style="width: 940px;">
                                            <textarea class="span12 ckeditor" id="post_content" name="content" title="">
                                                {$info.content}
                                            </textarea>
                                            <span class="err" id="err_content"></span>
                                            <p class="notic"></p>
                                        </dd>
                                    </dl>
                                    <div class="bot" style="padding: 20px 50px;">
                                        <a href="JavaScript:void(0);" class="ncap-btn-big ncap-btn-green" id="submitBtn">
                                            确认提交
                                        </a>
                                    </div>
                                </div>
                                <input type="hidden" name="status" value="1">
                                <input type="hidden" name="cat_id" value="15">
                                <input type="hidden" name="article_id" value="{$info.article_id}">
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<include file="public/footer" />
<script>
    var url="{:url('Admin/Ueditor/index',array('savePath'=>'article'))}";
    var ue = UE.getEditor('post_content',{
        serverUrl :url,
        zIndex: 999,
        initialFrameWidth: "80%", //初化宽度
        initialFrameHeight: 300, //初化高度
        focus: false, //初始化时，是否让编辑器获得焦点true或false
        maximumWords: 99999, removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
        pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
        autoHeightEnabled: true
    });

    $(document).on("click", '#submitBtn', function () {
        verifyForm();
    });
    function verifyForm(){
        $('span.err').hide();
        $.ajax({
            type: "POST",
            url: "{:U('User/articleEdit')}",
            data: $('#add_post').serialize(),
            dataType: "json",
            error: function () {
                layer.alert("服务器繁忙, 请联系管理员!");
            },
            success: function (data) {
                if (data.status === 1) {
                    layer.msg(data.msg, {icon: 1,time: 1000}, function() {

                        location.href = "{:U('User/articleList')}";
                    });

                } else if(data.status === 0) {
                    layer.msg(data.msg, {icon: 2,time: 1000});
                }
            }
        });
    }
</script>
</body>
</html>